clear all
set more off
global dpath "[Userpath]\data and code"

use "$dpath\data\deathratecontrol.dta",replace
joinby code using "$dpath\data\DSPcode.dta",unmatched(both)
keep if _merge==3
drop _merge
order countycode,after(code)

joinby countycode year using "$dpath\data\countypollution.dta", unmatched(both)
keep if _merge==3
drop _merge

drop if year>=autoyear
replace auto=1 if year>=autoyear-1

cd "$dpath\results"

drop if lcod==.
drop if lwastewater==.

reghdfe auto digestivecancerdr lifeexpectancy nocancerdigestivedr lungcancerdr respiratorydr, absorb(code year) cluster(citycode)
estimates store reg1
reghdfe auto digestivecancerdr lifeexpectancy nocancerdigestivedr lungcancerdr respiratorydr lcod lwastewater lngdp lnbed, absorb(code year) cluster(citycode)
estimates store reg2

esttab reg1 reg2 using TableAVI.rtf,replace b(%9.3f) se scalar(N r2_a) title(Table AVI) star(* 0.1 **  0.05  *** 0.01)
	   
est clear

